const sql = require('./sqlConnection');
const connection = sql.sqlConnection;

module.exports = {
    getPostByPage(pageIndex,pageSize,callback){
        let sql = `SELECT posts.id,title,posts.\`status\`,created,nickname,\`name\` 
        FROM posts 
        JOIN users ON posts.user_id=users.id
        JOIN categories ON posts.category_id=categories.id    
        LIMIT ${(pageIndex-1)*pageSize},${pageSize}`;
        connection.query(sql,(err,result)=>{
            callback(err,result);
        })
    }
} 